<?php
class LoginModel extends Model {
	
	public function doLogin($login, $password) {
		$queryString = sprintf("
			SELECT 
				*
			FROM
				`user` AS `u`
			WHERE
				`u`.`login` = '%s'
			AND
				`u`.`password` = MD5('%s')
			", 
			$login, $password
		);
        $result = $this->_sqlInstance->query($queryString);
        if($result) {
            foreach ($result as $row) {
                $user = new User($row->id);
            }
            return $user;
        }
	}
}